﻿namespace Rsdn.Janus
{
    using System.ComponentModel;
    using System.Drawing.Design;
    using System.IO;
    using JanusLibAing;

    [TypeConverter(typeof(ExpandableObjectConverter))]
    public class EditorAutoSaveConfig
    {
        private const bool _defaultUseEditorAutoSave = true;
        private bool _useEditorAutoSave = _defaultUseEditorAutoSave;

        private static readonly string _defaultPathEditorAutoSave = Path.GetTempPath();
        private string _pathEditorAutoSave = _defaultPathEditorAutoSave;

        private const int _defaultPeriodEditorAutoSave = 5; //5 second
        private int _periodEditorAutoSave = _defaultPeriodEditorAutoSave;

        public override string ToString()
        {
            return string.Empty;
        }

        [SortIndex(10)]
        [DefaultValue(_defaultUseEditorAutoSave)]
        [JanusDisplayName(SR.Config.EditorAutoSave.Use.DisplayNameResourceName)]
        [JanusDescription(SR.Config.EditorAutoSave.Use.DescriptionResourceName)]
        public bool UseEditorAutoSave
        {
            get { return _useEditorAutoSave; }
            set { _useEditorAutoSave = value; }
        }

        [SortIndex(20)]
        [JanusDisplayName(SR.Config.EditorAutoSave.Path.DisplayNameResourceName)]
        [JanusDescription(SR.Config.EditorAutoSave.Path.DescriptionResourceName)]
        [Editor(typeof(SelectDirectoryEditor), typeof(UITypeEditor))]
        public string PathEditorAutoSave
        {
            get { return _pathEditorAutoSave; }
            set { _pathEditorAutoSave = value; }
        }

        [SortIndex(30)]
        [DefaultValue(_defaultPeriodEditorAutoSave)]
        [JanusDisplayName(SR.Config.EditorAutoSave.Period.DisplayNameResourceName)]
        [JanusDescription(SR.Config.EditorAutoSave.Period.DescriptionResourceName)]
        public int PeriodEditorAutoSave
        {
            get { return _periodEditorAutoSave; }
            set { _periodEditorAutoSave = value; }
        }

    }


}